<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class mail_model extends MY_Model {

	protected $table		= "mail_setting";
	protected $key			= "id";
	protected $soft_deletes	= true;
	protected $date_format	= "datetime";
	protected $set_created	= false;
	protected $set_modified = false;

	//---------------------------------------------------------------
		
	function send_to($ids_array)
	{
		$this->db->select('contacts.id as con_id, contacts.email, titles.name as title, titles.en_name as title_en, contacts.name_ar,contacts.name_en, company.email as com_mail, company.name as com_name');
		$this->db->from('contacts');
		$this->db->join('company' ,'company.id = contacts.company');
		$this->db->join('titles' ,'titles.id = contacts.title');
		
		
		foreach($ids_array['ids'] as $row)
			$this->db->or_where('company.id',$row);	
			
		$this->db->where('company.deleted',false);
		$this->db->where('contacts.deleted',false);	
		$list = $this->db->get();
		
		return $list;
	}
	
	function delete_template($id)
	{
		$this->db->where('id', $id);
		return $this->db->delete("mail_template");
	}

}
